package cn.iocoder.yudao.module.vlog.history.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.vlog.history.dal.dataobject.VLogBrowseHistoryDO;
import cn.iocoder.yudao.module.vlog.history.service.VLogBrowseHistoryService;
import cn.iocoder.yudao.module.vlog.history.vo.VLogBrowseHistoryPageReqVO;
import cn.iocoder.yudao.module.vlog.history.vo.VLogBrowseHistoryRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 视频浏览记录")
@RestController
@RequestMapping("/vlog/browse-history")
@Validated
public class VLogBrowseHistoryController {
    @Resource
    private VLogBrowseHistoryService browseHistoryService;

    @GetMapping("/page")
    @Operation(summary = "获得视频浏览记录分页")
    @PreAuthorize("@ss.hasPermission('vlog:browse-history:query')")
    public CommonResult<PageResult<VLogBrowseHistoryRespVO>> getBrowseHistoryPage(@Valid VLogBrowseHistoryPageReqVO pageReqVO) {
        PageResult<VLogBrowseHistoryDO> pageResult = browseHistoryService.getBrowseHistoryPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, VLogBrowseHistoryRespVO.class));
    }

}
